import strutils

proc decode*(s: string): string = 
  for b in s:
    case b
    of {'a' .. 'z'}:
      result.add chr(ord('z') + ord('a') - ord(b))
    of {'A' .. 'Z'}:
      result.add chr(ord('z') + ord('A') - ord(b))
    of Digits:
      result.add b
    else:
      discard

proc separate(s: string, limit: int): string = 
  var lastSpace = 0
  for c in s:
    if lastSpace + limit == result.len: 
      result.add ' '
      lastSpace += limit + 1
    result.add c

proc encode*(s: string): string = 
  s.decode.separate 5
